package algorithm.poj.p2000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;
import java.text.DecimalFormat;
import java.util.StringTokenizer;

public class P2209 {

	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P2209.class.getResource("P2209.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));

		int n = Integer.valueOf(stdin.readLine().trim());
		int e = Integer.valueOf(stdin.readLine().trim());
		int s = 0;
		StringTokenizer st = new StringTokenizer(stdin.readLine());
		if (e%2 == 0) {
			for (int i = 0; i < n; i ++) {
				int t = Integer.valueOf(st.nextToken());
				s += Math.pow(t, e);
			}
		} else {
			for (int i = 0; i < n; i ++) {
				int t = Integer.valueOf(st.nextToken());
				if (t > 0) {
					s += Math.pow(t, e);
				}
			}
		}
		
		System.out.println(new DecimalFormat("##0").format(s));
	}
}